﻿using ReservationModule.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReservationModule
{ 
    public partial class HMS : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          
            
            if (Session["Login"] == "true")
            {
                tbxPassword.Visible = false;
                tbxUsername.Visible = false;
                lblPassword.Visible = false;
                DDLStaffType.Visible = false;
                btnLogin.Visible = false;

                lblUsername.Text = "Welcome : " + Session["UserName"];
                btnLogout.Visible = true;
            }
            
            if (Session["Login"] == "false")
            {
                tbxPassword.Visible = true;
                tbxUsername.Visible = true;
                lblPassword.Visible = true;
                DDLStaffType.Visible = true;
                btnLogin.Visible = true;

                lblUsername.Text = "Username:";
                btnLogout.Visible = false;
            }

           

        }

        protected void btnLogin_Click1(object sender, EventArgs e)
        {

            string login1 = DBManager.validateLogin1(tbxUsername.Text, tbxPassword.Text, DDLStaffType.Text);

            Session["UserName"] = tbxUsername.Text;
            Session["StaffType"] = DDLStaffType.Text;
            Session["Login"] = login1;

            if (login1.Equals("true"))
            {
                Response.Redirect("ModuleMenuPage.aspx");
            }
            else
            {
                Response.Redirect("LoginFail.aspx");
            }
            
        }

        protected void DDLStaffType_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            Session["UserName"] = "";
            Session["StaffType"] = "";
            Session["Login"] = "false";

            Response.Redirect("Index.aspx");
        }
    }
}